<?php
class IndexAction extends Action{
	public function index(){
		$Goods=M('Goods');
		$Ads=M('Ads');
		$Order=M('Orders_item');
		$goods=$Goods->where("cat_id=14 and is_post='0'")->select();
		//商品
		$this->goods2=$Goods->where("cat_id=19 and is_post='0'")->select();
		$this->goods3=$Goods->where("is_post='0'")->limit(5)->select();
		$this->hot=$Goods->where("is_post='0'")->order('view_count desc')->limit(6)->select();
		$this->hot1=$Goods->where("is_post='0'")->order('view_count desc')->limit(6,6)->select();

		$this->goods_hot=$Goods->where("is_post='0'")->order('buy_count desc')->limit(2,5)->select();
		$this->goods_coup=$Goods->where("goods_label='price' and is_post='0'")->limit(5)->select();
		$this->goods_new=$Goods->where("is_post='0'")->order("uptime desc")->limit(5)->select();
		$this->goods_rec=$Goods->where("goods_label='rec' and is_post='0'")->limit(5)->select();

		//商城通知
		$Notice=M('Page_notice');
		$this->notice=$Notice->order('time desc')->limit(5)->select();

		//广告
		$this->topad = $Ads->where("place_tag='IndexAD01' and is_show='true'")->order("sorting")->find();
		$this->strollad = $Ads->where("place_tag='Indexlun' and is_show='true'")->order("sorting")->select();
		$this->goods_hot_right = $Ads->where("place_tag='Indexsir' and is_show='true'")->order("sorting")->find();
		$this->ad_left = $Ads->where("place_tag='indexleft' and is_show='true'")->order("sorting")->select();
		$this->ad_bot1 = $Ads->where("place_tag='indexbotl' and is_show='true'")->order("sorting")->limit(2)->select();
		$this->ad_bot2 = $Ads->where("place_tag='indexbotz' and is_show='true'")->order("sorting")->limit(4)->select();
		$this->ad_bot3 = $Ads->where("place_tag='indexbotr' and is_show='true'")->order("sorting")->limit(2)->select();
		$this->ad_song = $Ads->where("place_tag='indexsong' and is_show='true'")->order("sorting")->find();
		$this->ad_new = $Ads->where("place_tag='indexnew' and is_show='true'")->order("sorting")->find();
		$this->ad_title = $Ads->where("place_tag='indexleftc' and is_show='true'")->order("sorting")->limit(3)->select();

		$col_title = $Ads->where("place_tag like 'index_title%'")->select();
		foreach($col_title as $ad_info){
			$title_ad[$ad_info['place_tag']] = $ad_info['content'];
		}
		$this->assign("title_ad",$title_ad);

		//最新成交
		$this->order_list=$Order->join("e_orders ON e_orders_item.order_id=e_orders.order_id")->join("e_goods ON e_orders_item.goods_id=e_goods.goods_id")->join("e_member ON e_orders.member_id=e_member.member_id")->order("create_time desc")->limit(10)->select();

		$this->user=$_SESSION['euname'];
		$this->cat=R('Goods/goods_cat');
		$shop_cart=cookie('shopcart');
		$this->cart_num=!empty($shop_cart)?count(unserialize(stripslashes($shop_cart))):0;
		$this->name=C('WEB_NAME');
		$this->nowtime=time()-6*60*60;
		$this->assign('goods',$goods);
		$this->display();
		
	}


}
?>